package com.wanbangee.marksystem.service.imp;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wanbangee.marksystem.dao.StatisticsAverageRankingDao;
import com.wanbangee.marksystem.dao.StatisticsScoreReportDao;
import com.wanbangee.marksystem.dao.StatisticsSubReportDao;
import com.wanbangee.marksystem.entities.StatisticsAverageRanking;
import com.wanbangee.marksystem.entities.StatisticsSubReport;
import com.wanbangee.marksystem.service.StatistisGradeReportService;

@Service
public class StatistisGradeReportServiceImp implements StatistisGradeReportService {
	@Autowired
	public StatisticsSubReportDao statisticsSubReportDao;
	
	@Autowired
	public StatisticsAverageRankingDao statisticsAverageRankingDao;
	
	@Autowired
	public StatisticsScoreReportDao statisticsScoreReportDao;

	@Override
	public List<StatisticsSubReport> selectAvgAndTotal(Integer examId) {
		return this.statisticsSubReportDao.selectAvgAndTotal(examId);
	}

	@Override
	public List<StatisticsAverageRanking> selectStatisticsAverageRankingByExamIdAndSubId(Integer examId,
			Integer subId) {
		
		//return this.statisticsAverageRankingDao.selectStatisticsAverageRanking(examId, subId);
		if(subId == -1) {
			return this.statisticsScoreReportDao.selectStatisticsAverageRankingByexamId(examId);
		} 
		return this.statisticsAverageRankingDao.selectStatisticsAverageRankingByExamIdAndSubId(examId, subId);
		
	}
	
	@Override
	public Map<String,Object> selectAvgAndTotalScoreByexamId(Integer examId) {
		
		return this.statisticsScoreReportDao.selectAvgAndTotalScoreByexamId(examId);
	}

}
